<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script type="text/javascript">
    function getDiv(){
      var div1 = document.getElementById("div1");
      div1.innerText="<a href='www.baidu.com'>百度</a>"
      // var divs = document.getElementsByName("mydiv");
      // console.log(divs[0]);
      // console.log(divs[1]);
    }
  </script>
</head>
<body onload = "getDiv()">
  <div id="div1" name="mydiv">div1</div>
  <div name="mydiv">div2</div>
</body>
</html>